Flash memory management method and flash memory system

ABSTRACT

A flash memory management method for effectively deleting a file and a flash memory system, the flash memory system including: a flash memory; and an interface determining whether a sensed sector write operation instructs a file system to delete a file by examining metadata of the file system and deleting data in the flash memory corresponding to the file if the sensed sector write operation instructs deletion of the file. Accordingly, an interface layer between the flash memory and the file system can prevent unnecessary data from being copied in a future garbage collection process by recognizing a delete operation of the file system and quickly performing a future rewrite operation since actual data blocks are erased in file deletion.

CROSS-REFERENCE TO RELATED APPLICATION

This application claims the benefit of Korean Patent Application No.2005-76546, filed on Aug. 20, 2005 in the Korean Intellectual PropertyOffice, the disclosure of which is incorporated herein in its entiretyby reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

An aspect of the present invention relates to a flash memory, and moreparticularly, to a flash memory management method and a flash memorysystem for effectively deleting a file.

2. Description of the Related Art

A flash memory is a kind of Electrically Erasable and Programmable ReadOnly Memory (EEPROM) and is largely divided into a NOR type flash memorysupporting byte input/output (I/O) and a NAND type flash memorysupporting only page I/O. The NOR type flash memory is usually used as amemory for codes because of a fast read speed and a slow write speed,and the NAND type flash memory is mainly used as a bulk data storageunit because of a relatively fast write speed and a low cost per unitspace.

However, unlike a disk drive, for the flash memory, an erase operationmust be performed in advance to perform a rewrite operation, the flasherase operation is performed in a much greater block unit than a writeoperation, and the execution time of the flash erase operation is long.When the flash memory is used as an auxiliary memory unit, thesecharacteristics impede the use of a file system of a hard disk drive inthe flash memory. To solve this, a flash translation layer (FTL), whichis a middleware between a disk file system and a flash memory, wassuggested in Korean Patent No. 389867 and U.S. Pat. No. 5,404,485. TheFTL is an interface layer for freely reading and writing from and in aflash memory as a hard disk drive.

FIG. 1 is a general hardware configuration of a device using a flashmemory. A central processing unit (CPU) 101 executes an applicationprogram stored in a Random Access Memory (RAM) 104 and issues a seriesof commands for a flash controller 102 to read or write data from or ina flash memory 103, and the flash controller 102 directly controls theflash memory 103.

FIG. 2 is a software stack of a flash memory system using an FTL, whichincludes an application 201, a file system 202, an FTL 203, and a flashmemory 204. The file system 202, which has received a read/write requestfrom the application 201, outputs a sector address, which is aread/write object, to the FTL 203, and the FTL 203 translates the sectoraddress to a physical address (a block number and a page number) andoutputs the physical address to the flash memory 204.

As illustrated in FIG. 3, an FTL translates a sector address or number,which is a logical address of a virtual disk, to a block number and apage number, which is a physical address of a flash memory. In addition,as illustrated in FIG. 4, an FTL emulates a read/program/erase operationperformed in a flash device similar to a read/write operation performedin a disk device.

An address translation of an FTL can be achieved using a virtual mappingtable. A mapping method is largely divided into a page mapping methodand a block mapping method. The page mapping method performs the addresstranslation in a page basis (below 2 KB), and the block mapping methodperforms the address translation in a block basis (below 128 KB).

FIG. 5 illustrates an address translation mechanism according to theblock mapping method. For example, a logical address ‘sector 6’ isdivided into a logical block number and a logical offset, respectivelymapped to a physical block number and a physical offset, and translatedto ‘page2 of block0’ of a flash memory.

Since an FTL emulates a flash device, to show it as a randomlyreadable/writable disk using the block mapping method, a disk-based filesystem, such as a file allocation table (FAT) file system, can belocated above the FTL. FIG. 6 illustrates a structure of an FAT table ofan FAT file system, wherein a file is represented as a linked list ofaddresses in which real data is stored, and this file information ismanaged as a table. Referring to FIG. 6, FAT entries 0, 1, and 5indicate free areas in which data is not recorded, a file A is stored inan area indicated by FAT entries 4, 7, and 2, and a file B is stored inan area indicated by FAT entries 6 and 3. The FAT table is stored in abeginning portion of a disk separately from an area in which contents offiles are stored, and when a file is deleted, only the FAT table isupdated, and contents in real data blocks corresponding to the deletedfile indicated by the FAT table remain.

In other words, when an FAT file system is used as an upper layer of anFTL, when performing a file deletion, a relevant file is not reallydeleted but only an FAT table and a directory entry corresponding to thefile are updated, and therefore the FTL, which is a lower layer, doesnot know that sectors of the deleted file are invalid. Likewise, in mostother file systems, only metadata of a deleted file is updated, and dataof sectors in which the file has been actually recorded remains in aflash memory.

The mechanism described above is effective in an infinitely overwritabledevice, such as a hard disk but ineffective in a flash device. An FTLprovides abstraction to allow a flash memory to be logically rewritten.However, in reality, when a rewrite occurs, data must be recorded in afree space of the flash memory, and if free space does not exist, agarbage collection or merge operation for generating new free blocksmust be performed, and therefore processing speed is slowed.

FIG. 7 illustrates a garbage collection process of an FTL, which wassuggested in Korean Patent No. 389867. Here, data of one logical blockcan be recorded in a maximum of two blocks (a data block and a logblock), and when data cannot be rewritten in the two blocks any more dueto continuous rewrite operations, a merge operation for merging the twoblocks into one is performed, and then a rewrite operation proceeds.That is, in FIG. 7, the data block and the log block become erasableblocks after merged to a free block. According to this mechanism, thetime for performing a block copy operation and two flash eraseoperations is required for a sector write operation. In addition, evenif a file is deleted from a file system, only metadata, such as an FATtable, is updated, and an actual data block remains as is, andaccordingly, the FTL recognizes all data of the deleted file as a validpage and copies them too. If FTL can know whether a certain sector hasdata of an actually deleted file, such an overhead can be removed.

SUMMARY OF THE INVENTION

According to an aspect of the present invention, there is provided aflash memory management method for reducing a load due to an unnecessarycopying of data in garbage collection, thus guaranteeing the same writespeed of a first write when rewriting a file of a flash memory afterdeletion of the file by an interface module, such as a flash translationlayer (FTL), recognizing the deletion of the file from a file systemlocated at an upper layer and then invalidating a flash memory areacorresponding to the deleted file or erasing data in the flash memoryarea and a flash memory system using the same.

According to another aspect of the present invention, there is provideda flash memory management method for performing an effective writeoperation by sensing that a file system performs a write operation ofmetadata and determining whether the write operation is to delete a fileand a flash memory system using the same.

According to an aspect of the present invention, there is provided aflash memory management method using a file system, the method includingsensing a sector write operation; determining whether the sensed sectorwrite operation relates to an area in which metadata of the file systemis stored; and managing a flash memory according to the determination.

According to another aspect of the present invention, the managing ofthe flash memory includes: if the sector write operation relates to thearea in which metadata of the file system is stored, determining atarget of the sector write operation by comparing information on themetadata area with information on a write buffer of the sector writeoperation.

According to another aspect of the present invention, the managing ofthe flash memory further includes: if the target of the sector writeoperation is a deletion of a file, deleting data of the flash memorycorresponding to the file.

According to another aspect of the present invention, the deleting ofthe file includes: invalidating pages of the flash memory in which thedata is stored by indicating that the pages are in a deleted area.

According to another aspect of the present invention, the deleting ofthe file further includes: checking a state of blocks to which theinvalidated pages belong; and erasing blocks whose all pages areinvalidated among the blocks by performing a flash erase operation.

According to another aspect of the present invention, the managing ofthe flash memory further includes: recording the information on thewrite buffer in the metadata area.

According to another aspect of the present invention, there is provideda flash memory management method using a file system, the methodincludes: reading information on a boot sector when the file system ismounted; obtaining information of the file system by examining theinformation on the boot sector; and managing a flash memory according tothe information of the file system.

According to another aspect of the present invention, the managing ofthe flash memory includes: obtaining a type of the file system and aposition of an area in which metadata is stored using the information ofthe file system.

According to another aspect of the present invention, there is provideda flash memory system using a file system, the flash memory systemincludes: a flash memory; and an interface determining whether a sensedsector write operation instructs the file system to delete a file byexamining metadata of the file system and deleting data in the flashmemory corresponding to the file if the sector write operation instructsthe file deletion.

According to another aspect of the present invention, the flash memorysystem further includes: a nonvolatile random access memory (RAM) inwhich the metadata is recorded.

Additional aspects and/or advantages of the invention will be set forthin part in the description which follows and, in part, will be obviousfrom the description, or may be learned by practice of the invention.

BRIEF DESCRIPTION OF THE DRAWINGS

These and/or other aspects and advantages of the invention will becomeapparent and more readily appreciated from the following description ofthe embodiments, taken in conjunction with the accompanying drawings ofwhich:

FIG. 1 is a general hardware configuration of a device using a flashmemory;

FIG. 2 is a software configuration of a flash memory system using aflash translation layer (FTL);

FIG. 3 illustrates an address translation mechanism of an FTL;

FIG. 4 illustrates operations of an FTL;

FIG. 5 illustrates a block mapping method of an address translationmechanism of an FTL;

FIG. 6 illustrates a structure of an FAT table;

FIG. 7 illustrates a garbage collection process of an FTL;

FIG. 8 is a flowchart of a flash management method according to anembodiment of the present invention;

FIGS. 9A and 9B are diagrams illustrating comparison of an FAT tablebefore file deletion to the FAT table after the file deletion;

FIG. 10 is a block diagram of a flash memory system according to anembodiment of the present invention; and

FIG. 11 is a graph illustrating a result of performance comparisonbetween a flash management method according to an embodiment of thepresent invention and flash management methods according to the relatedart.

DETAILED DESCRIPTION OF THE EMBODIMENTS

Reference will now be made in detail to the present embodiments of thepresent invention, examples of which are illustrated in the accompanyingdrawings, wherein like reference numerals refer to the like elementsthroughout. The embodiments are described below in order to explain thepresent invention by referring to the figures.

FIG. 8 is a flowchart illustrating a mechanism for processing a sectorwrite operation in a flash management method according to an embodimentof the present invention. A method of obtaining basic information of afile system in an interface, such as an FTL, is by examining a bootsector. The boot sector can be read when the file system is mounted orgenerated, and the basic information of the file system, such as whichtype of file system and where metadata of the file system is recorded,can be obtained by examining information on the boot sector and used tomanage a flash memory. Although an aspect of the present embodiment isdescribed based on an FAT file system, the present invention is notlimited to a specific file system.

When an FTL senses a sector write operation, it is determined whetherthe sector write operation relates to a boot sector in operation S801.If the sector write operation relates to the boot sector, information onthe boot sector is examined in operation S808, and an FTL writeoperation is performed based on the examination result in operationS807.

If the sector write operation does not relate to the boot sector, it isdetermined whether the sector write operation relates to an area inwhich metadata of a file system is stored in operation S802. Asdescribed above, since a location of the metadata of the file system canbe obtained by using information on the file system obtained when thefile system is mounted, it can be known whether the sector writeoperation relates to the metadata. In the present embodiment, it isdetermined whether the sector write operation relates to an area inwhich an FAT table is stored.

If the sector write operation does not relate to the FAT area, a generalFTL write operation corresponding to the sector write operation isperformed in operation S807. That is, the FTL converts a logical addressto which the sector write operation is applied to a physical address andrecords contents of a write buffer in the physical address of the flashmemory.

When the sensed sector write operation relates to the area in which themetadata is stored, a target of the sector write operation is determinedby comparing existing information recorded in the metadata area withinformation stored in the write buffer for the sector write operationusing the method described below.

When the sector write operation relates to the FAT area, metadatainformation, i.e., FAT entries, of a sector corresponding to adestination of the sector write operation is read from the flash memoryin operation S803, the read FAT entries are compared to new FAT entries,which are contents of the write buffer, in operation S804, and it isexamined whether newly deleted FAT entries exist in operation S805.Since a write unit of the flash memory is a sector, the comparison mustbe performed for each sector. That is, which FAT entries have beenupdated are examined by comparing one by one all FAT entries included inthe sector corresponding to the destination of the sector writeoperation with all FAT entries included in a sector stored in the writebuffer. When an i^(th) FAT entry of the FAT table is compared, if anexisting i^(th) FAT entry is not 0 while data to be newly written is 0,i.e., if old(i)!=0 and new(i)=0, the i^(th) FAT entry indicates a flashmemory area deleted by a file deletion operation of the file system, andif such FAT entries are discovered, the sensed sector write operationinstructs file deletion.

In the comparison process, since a logical block address indicated by adeleted FAT entry can be translated to a block number and a page numberof the flash memory using a mapping function of the FTL, a physicaladdress corresponding to a file to be deleted can be obtained. Data ofthe flash memory corresponding to the file to be deleted is deletedusing the physical address, and the data deletion from the flash memoryis performed using invalidating and erase operations. In other words,pages having the physical address are invalidated by marking a deletedarea, and a state of blocks to which these pages belong is examined. Ifa block of which all pages are invalidated exists, a new block isgenerated by erasing the block through the flash erase operation inoperation S806.

Finally, according to the initially sensed sector write operation, theinformation stored in the write buffer is recorded in the sector in theFAT area in operation S807.

FIGS. 9A and 9B are diagrams illustrating a comparison of an FAT tablebefore and after file deletion. Referring to FIGS. 9A and 9B, files Aand B exist in the FAT table at first, and then the file A is deleted.As illustrated in FIG. 9A, if data to be newly written in FAT entries 4,7, and 2 of the file A are all ‘0s’ while values of the FAT entries 4,7, and 2 are ‘7’, ‘2’, and ‘eof’, it can be anticipated that a target ofa sensed sector write operation is deletion of the file A. In this case,areas of a flash memory corresponding to the FAT entries 4, 7, and 2 areinvalidated or erased according to the algorithm illustrated in FIG. 8,and the values of the FAT entries 4, 7, and 2 are changed to ‘0’ asillustrated in FIG. 9B.

FIG. 10 is a block diagram of a flash memory system 1000 according to anembodiment of the present invention, which includes a flash memory 1001and an interface 1002 and links to a file system 1004. In addition,performance can be more improved by adding a nonvolatile RAM (NVRAM)1003 to the flash memory system 1000.

The interface 1002 is a device performing the flash memory managementmethod described above and determines whether a sensed sector writeoperation is to delete a file by reading and examining contents ofcurrent metadata and comparing the contents of the current metadata withcontents of a write buffer of the sector write operation. If the sectorwrite operation is to delete a file, the interface 1002 actually deletesdata in the flash memory 1001 corresponding to the file. If the metadataof the file system is stored in the NVRAM 1003, when a target of thesector write operation is determined, the comparison of the data can bedirectly performed in the NVRAM 1003 instead of reading the metadatafrom the flash memory 1001 and comparing with data to be newly written,therefore reducing operation time.

As described above, according to embodiments of the present invention,an FTL can recognize a delete operation of an upper layer, preventunnecessary data from being copied in a future garbage collectionprocess, and quickly perform a future rewrite operation since actualdata blocks are erased in file deletion.

These characteristics are very useful for products, such as a camcorder,needing to store data in real-time. That is, while a write speed may notsatisfy real-time requirements when recording is repeatedly performedusing a camcorder according to the related art, performance similar toan initial write operation can be obtained in a rewrite operationaccording to an aspect of the present invention, and therefore real-timeperformance can be dramatically increased.

FIG. 11 is a graph illustrating test results by which thischaracteristic can be recognized.

From the left, the graph shows test results of a case 1101 where a flashfile system according to U.S. Pat. No. 5,404,485 is implemented, a case1102 where a flash memory management method according to Korean PatentNo. 389867 is implemented, and a case 1103 where a flash memorymanagement method according to an aspect of the present invention isimplemented. Conditions are all the same, and the results arerespectively obtained by measuring the times taken for (1) a case wheredata is initially fully written (≡), (2) a case where the data recordedin (1) is deleted (▪), and (3) a case where data is fully recorded again(□). As illustrated in FIG. 11, according to an aspect of the presentinvention, a rewrite operation can maintain almost the same write speedof an initial write operation.

In addition, since comparison of new and old data can be directlyperformed in an NVRAM by storing an FAT table in the NVRAM, theperformance can be further increased.

While this invention has been particularly shown and described withreference to embodiments thereof, it will be understood by those skilledin the art that various changes in form and details may be made thereinwithout departing from the spirit and scope of the invention as definedby the appended claims. The above-described embodiments should beconsidered in a descriptive sense only and are not for purposes oflimitation. Therefore, the scope of the invention is defined not by thedetailed description of the invention but by the appended claims, andall differences within the scope will be construed as being included inthe present invention.

1. A flash memory management method using a file system, the methodcomprising: sensing a sector write operation; determining whether thesector write operation relates to an area in which metadata of the filesystem is stored; and managing a flash memory according to thedetermination.
 2. The method of claim 1, wherein the managing of theflash memory comprises: if the sector write operation relates to thearea in which the metadata of the file system is stored, determining atarget of the sector write operation by comparing information on themetadata area with information on a write buffer of the sector writeoperation.
 3. The method of claim 2, wherein the managing of the flashmemory further comprises: if the target of the sector write operation isdeletion of a file, deleting data of the flash memory corresponding tothe file.
 4. The method of claim 3, wherein the deleting of the filecomprises: invalidating pages of the flash memory in which the data isstored by indicating that the pages are in a deleted area.
 5. The methodof claim 4, wherein the deleting of the file further comprises: checkinga state of blocks to which the invalidated pages belong; and erasing theblocks whose all pages are invalidated among the blocks by performing aflash erase operation.
 6. The method of claim 5, wherein the managing ofthe flash memory further comprises: recording the information on thewrite buffer in the metadata area.
 7. A flash memory management methodusing a file system, the method comprising: reading information on aboot sector when the file system is mounted; obtaining information onthe file system by examining the information on the boot sector; andmanaging a flash memory according to the information on the file system.8. The method of claim 7, wherein the managing of the flash memorycomprises: obtaining a type of the file system and a position of an areain which metadata is stored using the information on the file system. 9.The method of claim 8, wherein the managing of the flash memory furthercomprises: sensing a sector write operation; determining whether thesector write operation relates to an area in which the metadata of thefile system is stored; and if the sector write operation relates to thearea in which the metadata of the file system is stored, determining atarget of the sector write operation by comparing information on themetadata area with information on a write buffer of the sector writeoperation.
 10. The method of claim 9, wherein the managing furthercomprises: if the target of the sector write operation is deletion of afile, deleting data stored in the flash memory corresponding to thefile.
 11. The method of claim 10, wherein the deleting of the filecomprises: invalidating pages of the flash memory in which the data isstored by indicating that the pages are in a deleted area.
 12. Themethod of claim 11, wherein the deleting of the file further comprises:checking a state of blocks to which the invalidated pages belong; anderasing the blocks whose all pages are invalidated among the blocks byperforming a flash erase operation.
 13. A flash memory system using afile system, the flash memory system comprising: a flash memory; and aninterface determining whether a sensed sector write operation instructsthe file system to delete a file by examining metadata of the filesystem and deleting data in the flash memory corresponding to the fileif the sensed sector write operation instructs the file deletion. 14.The flash memory system of claim 13, wherein the interface determinesthat a target of the sensed sector write operation instructs thedeletion of the file by comparing information on a metadata area withinformation on a write buffer of the sector write operation if thesensed sector write operation relates to the metadata area in which themetadata of the file system is stored.
 15. The flash memory system ofclaim 14, wherein the interface deletes the data by invalidating pagesof the flash memory in which the data is stored by indicating that thepages are in a deleted area.
 16. The flash memory system of claim 15,wherein the interface deletes the data by checking a state of blocks towhich the invalidated pages belong and erasing the blocks whose allpages are invalidated among the blocks by performing a flash eraseoperation.
 17. The flash memory system of claim 14, further comprising:a nonvolatile random access memory (NVRAM) in which the metadata isrecorded.
 18. The flash memory system of claim 13, wherein the filesystem is a file allocation system (FAT) file.
 19. The flash memorysystem of claim 17, wherein when a target of the sensed sector writeoperation is determined, directly comparing the contents of the currentmetadata with the contents of the write buffer of the sector writeoperation in the NVRAM.
 20. The flash memory system of claim 14, whereinif the contents of a current i^(th) metadata is not 0 while data to benewly written is 0, the current i^(th)metadata indicates a flash memoryarea deleted by a file deletion operation of the file system, and ifsuch metadata is discovered, the sensed sector write operation instructsfile deletion.